#ifndef FORM_H
#define FORM_H

#include <QWidget>
#include <QString>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include "QThread"
#include "ui_form.h"

#define BK_RED      "background-color:red;"
#define BK_BULE     "background-color: rgb(85, 170, 255);"
#define BK_YELLOW   "background-color: rgb(255, 255, 127);"
#define BK_GREEN    "background-color:rgb(85, 255, 127)"
#define BK_WHITE    "background-color:white;"

enum TestFlag {
    TEST_FLAG_START,
    TEST_FLAG_PASS,
    TEST_FLAG_FAILED
};

enum TestEntry{
    TEST_ENTRY_WIFI,
    TEST_ENTRY_RTC,
    TEST_ENTRY_SDCARD,
    TEST_ENTRY_POWER,
    TEST_ENTRY_KEYBOARD
};

namespace Ui {
class Form;
}

class Form : public QWidget
{
    Q_OBJECT

public:
    explicit Form(QWidget *parent = 0);
    ~Form();
    void pushbutton_start(bool flag);

private slots:
    void Read_Data();

    void on_pushButton_start_clicked();


private:
    Ui::Form *ui;
    void clean_test_status(void);
    void WriteResultToFile(QString result);
    void start_flag_handle(QString line,int col,QGroupBox *gb);
    void write_productionID();

    void start_test(bool flag);

    QSerialPort  *port;
    QString       receive_data;

    bool          start_flag;
    int           result_line;
    bool          read_data_running;
};

#endif // FORM_H
